
#include<iostream>

using namespace std;
const int N = 110;
int ne[N], me[N];
int h;

int main()
{
	int a,b; cin >> a>>b;
	
	for (int i = 1; i <= a; i++)
	{
		if(i<a)
		ne[i] = i+1;
		else if (i == a)
		{
			ne[i] = 1;
		}
	}
	int key = 1;
	h = a;
	while (a)
	{
		h = ne[h];
		key++;
		if (key == b)
		{
			cout << ne[h] << " ";
			ne[h] = ne[ne[h]];
			key = 1;
			a--;
		}
	}

	return 0;
}
